﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Xml;

namespace FinPlusInterfaces
{
    public interface IPod : IEnumerable<IBean>, INotifyCollectionChanged, INotifyPropertyChanged
    {
        object this[string name, string user = null] { get; set; }
        int Id { get; set; }
        string LinkedId { get; set; }
        string Name { get; set; }
        string Error { get; set; }
        bool IsClosed { get; set; }
        bool IsDirty { get; set; }
        EventHandler<BeanEventArgs> BeanUpdate { get; set; }
        object Object { get; set; }
        Type Type { get; set; }
        string Invoke { get; set; }
        string ServiceKey { get; set; }
        
        void Update(IPod pod);

        void Refresh();

        IPod Create(int id);

        IPod Clone(int id);

        object Value(string name, object defaultValue = null);

        IBean Get<T>(string name, T defaultValue, PropertyChangedEventHandler changeEventHander = null);

        IBean Get(string name, PropertyChangedEventHandler changeEventHander = null);

        IBean Add(string name, object value, string user = "", int id = -1);

        IBean Add(string name, object value, string user, int id, int index, DateTime timeStamp);

        void Add(IDictionary<string, string> beans);

        bool TryAdd(IBean bean, bool withHistory = false, bool newKey = false);
        
        void Remove(IBean bean);

        bool IsEqual(IPod value);

        bool IsMatch(string where);

        string ToString();

        object[,] ToArray();

        void FromXml(ref int pos, int id, XmlElement xml, IDictionary<string, string> replace);

        void AddXml(XmlElement xmlBeans, ref int pos, IDictionary<string, string> replace);

        void AddXml(XmlAttributeCollection xmlBeans, ref int pos, IDictionary<string, string> replace);

        void ToXml(XmlDocument xmlDoc, string node);
    }
}
